import requests
import time
from bs4 import BeautifulSoup


def dou_yin():
    url = "https://www.iesdouyin.com/share/user/72673737181"
    HEADERS = {
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'zh-CN,zh;q=0.9',
        'pragma': 'no-cache',
        'cache-control': 'no-cache',
        'upgrade-insecure-requests': '1',
        'user-agent': "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
    }

    headers = {
        # "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
        # "Accept-Encoding": "gzip, deflate, br",
        # "Accept-Language": "Accept-Language",
        # "Cache-Control": "max-age=0",
        # "Connection": "keep-alive",
        # "Cookie": "_ga=GA1.2.1672978810.1560938540; _gid=GA1.2.1580457198.1560938540; _ba=BA0.2-20190620-5199e-1pRNoGuh8OuovSBIsId2",
        # "Host": "www.iesdouyin.com",
        # "Upgrade-Insecure-Requests": "1",
        "referer": "https://www.iesdouyin.com",
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
        # 'user-agent': "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1",
        # "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
    }
    # r = requests.post(url, headers=headers)
    # r.encoding = 'utf-8'
    params = {
        "u_code": "14d8ja02b",
        "timestamp": int(time.time()).__str__()
    }
    s = requests.session()
    r = s.get(url, params=params, headers=headers)
    # info = r.content

    # print(str(info, encoding="utf-8"))

    # print(r.text)
    soup = BeautifulSoup(r.text, "html.parser")
    print(soup.find("p").text)
    for p in soup.find("p"):
        print(p)

    # print(str(r.content, encoding="utf-8"))
    # print(r.content)


def game():
    url = "http://192.168.2.114/backend/login.php"
    data = {"account": "123", "passwd": "123"}
    r = requests.post(url, data=data)
    print(r.text)


from removebg import RemoveBg


def kou_tu():
    # rm = RemoveBg("crwYKtFf1ESX8RnS773UPAmB", "error.log")
    # rm.remove_background_from_img_file("")
    import os
    for paths, dirs, fs in os.walk(os.curdir):
        for path in dirs:
            print(path)




if __name__ == '__main__':
    # game()
    kou_tu()